

<script setup lang="ts">
import { useRequestWithRetry } from '@/hooks/useRequestWithRetry';

const async = () => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      reject('async data');
    }, 0);
  });
};

const { request, loading } = useRequestWithRetry(() => async(), {
  retryCount: 6,
  retryDelay: 1000,
});

const restRun = async function () {
  const res = await request();
  console.log('res', res);
}

</script>

<template>
  <div>
    <p v-if="loading">loading...</p>
    <button @click="restRun">发起重试</button>
  </div>
</template>
